﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DataAccess.Datatypes;
using BussinesLayer.Services;

namespace Mvc4.Areas.Admin.Controllers
{
    public class ConfigurationController : AdmController
    {
        private SiteServices ss = new SiteServices();

        public ActionResult Edit()
        {
            ViewBag.SiteName = "Configuration";
            Config config = ss.GetConfiguration();

            if (config == null)
            {
                return HttpNotFound();
            }

            return View(config);
        }

        //
        // POST: /Admin/Configuration/Edit/5

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit(Config config)
        {
            ViewBag.SiteName = "Configuration";

            if (ModelState.IsValid)
            {
                ss.ModifyConfiguration(config.InapropiateMax, config.InfractionMax, config.RankedGoodsMax);
                return RedirectToAction("Edit");
            }

            return View(config);
        }
    }
}